package ten;

public class 十七终止线程 implements Runnable {
    String name;
    boolean flag = true;

    public 十七终止线程(String name) {
        this.name = name;
    }

    @Override
    public void run() {
        int i = 0;
        while (flag) {
            i++;
            System.out.println(name + " study threading..." + i);
        }
    }

//    private void close() {
//        flag = false;
//    }

    public static void main(String[] args) {
        十七终止线程 th = new 十七终止线程("CT");
        new Thread(th).start();
        for (int i = 0; i < 100; i++) {
            if (i == 88) {
                System.out.println("thread stop");
//                th.close();
                th.flag = false;
            }
            System.out.println("main: " + i);
        }

    }
}
